package com.ruoyi.web.wh.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.Log;
import com.ruoyi.framework.enums.BusinessType;
import com.ruoyi.web.wh.domain.WhGoodstype;
import com.ruoyi.web.wh.service.IWhGoodstypeService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.Result;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 物品类型Controller
 *
 * @author ruoyi
 * @date 2025-02-23
 */
@RestController
@RequestMapping("/wh/goodstype")
public class WhGoodstypeController extends BaseController {
    @Autowired
    private IWhGoodstypeService whGoodstypeService;

    /**
     * 查询物品类型列表
     */
    @SaCheckPermission("wh:goodstype:list")
    @GetMapping("/list")
    public TableDataInfo list(WhGoodstype whGoodstype) {
        startPage();
        List<WhGoodstype> list = whGoodstypeService.selectWhGoodstypeList(whGoodstype);
        return getDataTable(list);
    }


    /**
     * 获取物品类型详细信息
     */
    @SaCheckPermission("wh:goodstype:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id) {
        return success(whGoodstypeService.selectWhGoodstypeById(id));
    }

    /**
     * 新增物品类型
     */
    @SaCheckPermission("wh:goodstype:add")
    @Log(title = "物品类型", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody WhGoodstype whGoodstype) {
        return toAjax(whGoodstypeService.insertWhGoodstype(whGoodstype));
    }

    /**
     * 修改物品类型
     */
    @SaCheckPermission("wh:goodstype:edit")
    @Log(title = "物品类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody WhGoodstype whGoodstype) {
        return toAjax(whGoodstypeService.updateWhGoodstype(whGoodstype));
    }

    /**
     * 删除物品类型
     */
    @SaCheckPermission("wh:goodstype:remove")
    @Log(title = "物品类型", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids) {
        return toAjax(whGoodstypeService.deleteWhGoodstypeByIds(ids));
    }
}
